class Student:

    def __init__(self, id, sname, age, xb):
        self.id = id

        self.sname = sname

        self.age = age

        self.xb = xb




class StudentManagementSystem:

    def __init__(self):

        self.students = []

    def add_student(self, student):

        self.students.append(student)

    def remove_student(self, student_id):

        for student in self.students:

            if student.id == student_id:

                self.students.remove(student)

                return True

        return False

    def search_student(self, student_id):

        for student in self.students:

            if student.id == student_id:

                return student

        return None

    def display_all_students(self):

        for student in self.students:

            print("学号: {}, 姓名: {}, 年龄: {}, 性别: {}".format(
                student.id, student.sname, student.age, student.xb))





# 创建学籍管理系统对象
sms = StudentManagementSystem()

while True:
    print("\n学籍管理系统")

    print("1. 添加学生信息")

    print("2. 删除学生信息")

    print("3. 查找学生信息")

    print("4. 显示所有学生信息")

    print("0. 退出系统")

    choice = input("请输入选择: ")

    if choice == '1':
        id = input("请输入学号: ")

        sname = input("请输入姓名: ")

        age = input("请输入年龄: ")

        xb = input("请输入性别: ")

        student = Student(id, sname, age, xb)

        sms.add_student(student)


        print("学生信息已添加成功！")

    elif choice == '2':

        student_id = input("请输入要删除的学号: ")

        if sms.remove_student(student_id):

            print("学生信息已删除成功！")

        else:

            print("学号不存在，删除失败！")



    elif choice == '3':

        student_id = input("请输入要查找的学号: ")

        student = sms.search_student(student_id)

        if student:

            print("学号: {}, 姓名: {}, 年龄: {}, 性别: {}".format(

                student.id, student.sname, student.age, student.xb))
        else:
            print("学号不存在！")

    elif choice == '4':

        sms.display_all_students()

    print("退出系统")